<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>GTypeModule</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GObject Reference Manual">
<link rel="up" href="rn01.html" title="API Reference">
<link rel="prev" href="GTypePlugin.html" title="GTypePlugin">
<link rel="next" href="gobject-The-Base-Object-Type.html" title="GObject">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="preface" href="pr01.html" title="Introduction">
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;Concepts">
<link rel="chapter" href="chapter-intro.html" title="Background">
<link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
<link rel="reference" href="rn01.html" title="API Reference">
<link rel="reference" href="rn02.html" title="Tools Reference">
<link rel="part" href="pt02.html" title="Part&#160;IV.&#160;Tutorial">
<link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
<link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
<link rel="chapter" href="howto-signals.html" title="How to create and use signals">
<link rel="part" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
<link rel="chapter" href="tools-gob.html" title="GObject builder">
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
<link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="GTypePlugin.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GObject Reference Manual</th>
<td><a accesskey="n" href="gobject-The-Base-Object-Type.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2852704" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2853058" class="shortcut">Description</a>
                  &#160;|&#160;
                  <a href="#id2853011" class="shortcut">Object Hierarchy</a>
                  &#160;|&#160;
                  <a href="#id2853036" class="shortcut">Implemented Interfaces</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="GTypeModule"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2852704"></a><span class="refentrytitle">GTypeModule</span>
</h2>
<p>GTypeModule &#8212; Type loading modules</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib-object.h&gt;


                    <a class="link" href="GTypeModule.html#GTypeModule-struct">GTypeModule</a>;
                    <a class="link" href="GTypeModule.html#GTypeModuleClass">GTypeModuleClass</a>;
<a
href="./../glib/glib/glib-Basic-Types.html#gboolean"
>gboolean</a>            <a class="link" href="GTypeModule.html#g-type-module-use">g_type_module_use</a>                   (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module);
void                <a class="link" href="GTypeModule.html#g-type-module-unuse">g_type_module_unuse</a>                 (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module);
void                <a class="link" href="GTypeModule.html#g-type-module-set-name">g_type_module_set_name</a>              (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name);
<a class="link" href="gobject-Type-Information.html#GType">GType</a>               <a class="link" href="GTypeModule.html#g-type-module-register-type">g_type_module_register_type</a>         (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         <a class="link" href="gobject-Type-Information.html#GType">GType</a> parent_type,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *type_name,
                                                         const <a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a> *type_info,
                                                         <a class="link" href="gobject-Type-Information.html#GTypeFlags">GTypeFlags</a> flags);
void                <a class="link" href="GTypeModule.html#g-type-module-add-interface">g_type_module_add_interface</a>         (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         <a class="link" href="gobject-Type-Information.html#GType">GType</a> instance_type,
                                                         <a class="link" href="gobject-Type-Information.html#GType">GType</a> interface_type,
                                                         const <a class="link" href="gobject-Type-Information.html#GInterfaceInfo">GInterfaceInfo</a> *interface_info);
<a class="link" href="gobject-Type-Information.html#GType">GType</a>               <a class="link" href="GTypeModule.html#g-type-module-register-enum">g_type_module_register_enum</a>         (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name,
                                                         const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GEnumValue">GEnumValue</a> *const_static_values);
<a class="link" href="gobject-Type-Information.html#GType">GType</a>               <a class="link" href="GTypeModule.html#g-type-module-register-flags">g_type_module_register_flags</a>        (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name,
                                                         const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GFlagsValue">GFlagsValue</a> *const_static_values);
#define             <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE:CAPS">G_DEFINE_DYNAMIC_TYPE</a>               (TN, t_n, T_P)
#define             <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS">G_DEFINE_DYNAMIC_TYPE_EXTENDED</a>      (TypeName, type_name, TYPE_PARENT, flags, CODE)

</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2853011"></a><h2>Object Hierarchy</h2>
<pre class="synopsis">

  <a class="link" href="gobject-The-Base-Object-Type.html#GObject">GObject</a>
   +----GTypeModule
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2853036"></a><h2>Implemented Interfaces</h2>
<p>
GTypeModule implements
 <a class="link" href="GTypePlugin.html" title="GTypePlugin">GTypePlugin</a>.</p>
</div>
<div class="refsect1" lang="en">
<a name="id2853058"></a><h2>Description</h2>
<p>
<a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> provides a simple implementation of the <a class="link" href="GTypePlugin.html" title="GTypePlugin"><span class="type">GTypePlugin</span></a>
interface. The model of <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> is a dynamically loaded module
which implements some number of types and interface
implementations. When the module is loaded, it registers its types
and interfaces using <a class="link" href="GTypeModule.html#g-type-module-register-type"><code class="function">g_type_module_register_type()</code></a> and
<a class="link" href="GTypeModule.html#g-type-module-add-interface"><code class="function">g_type_module_add_interface()</code></a>.  As long as any instances of these
types and interface implementations are in use, the module is kept
loaded. When the types and interfaces are gone, the module may be
unloaded. If the types and interfaces become used again, the module
will be reloaded. Note that the last unref can not happen in module
code, since that would lead to the caller's code being unloaded before
<a class="link" href="gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a> returns to it.
</p>
<p>
Keeping track of whether the module should be loaded or not is done by
using a use count - it starts at zero, and whenever it is greater than
zero, the module is loaded. The use count is maintained internally by
the type system, but also can be explicitly controlled by
<a class="link" href="GTypeModule.html#g-type-module-use"><code class="function">g_type_module_use()</code></a> and <a class="link" href="GTypeModule.html#g-type-module-unuse"><code class="function">g_type_module_unuse()</code></a>. Typically, when loading
a module for the first type, <a class="link" href="GTypeModule.html#g-type-module-use"><code class="function">g_type_module_use()</code></a> will be used to load
it so that it can initialize its types. At some later point, when the
module no longer needs to be loaded except for the type
implementations it contains, <a class="link" href="GTypeModule.html#g-type-module-unuse"><code class="function">g_type_module_unuse()</code></a> is called.
</p>
<p>
<a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> does not actually provide any implementation of module
loading and unloading. To create a particular module type you must
derive from <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> and implement the load and unload functions
in <a class="link" href="GTypeModule.html#GTypeModuleClass"><span class="type">GTypeModuleClass</span></a>.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2853224"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2853234"></a><h3>
<a name="GTypeModule-struct"></a>GTypeModule</h3>
<a class="indexterm" name="id2853247"></a><pre class="programlisting">typedef struct {
  gchar *name;
} GTypeModule;
</pre>
<p>
The members of the <span class="structname">GTypeModule</span> structure should not 
be accessed directly, except for the <em class="parameter"><code>name</code></em> field.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a>&#160;*<em class="structfield"><code>name</code></em>;</span></p></td>
<td>the name of the module

</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2853298"></a><h3>
<a name="GTypeModuleClass"></a>GTypeModuleClass</h3>
<a class="indexterm" name="id2853311"></a><pre class="programlisting">typedef struct {
  GObjectClass parent_class;

  gboolean (* load)   (GTypeModule *module);
  void     (* unload) (GTypeModule *module);
} GTypeModuleClass;
</pre>
<p>
In order to implement dynamic loading of types based on <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>, 
the <em class="parameter"><code>load</code></em> and <em class="parameter"><code>unload</code></em> functions in <a class="link" href="GTypeModule.html#GTypeModuleClass"><span class="type">GTypeModuleClass</span></a> must be implemented.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a class="link" href="gobject-The-Base-Object-Type.html#GObjectClass">GObjectClass</a>&#160;<em class="structfield"><code>parent_class</code></em>;</span></p></td>
<td>the parent class
</td>
</tr>
<tr>
<td><p><span class="term"><em class="structfield"><code>load</code></em>&#160;()</span></p></td>
<td>loads the module and registers one or more types using
  <a class="link" href="GTypeModule.html#g-type-module-register-type"><code class="function">g_type_module_register_type()</code></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="structfield"><code>unload</code></em>&#160;()</span></p></td>
<td>unloads the module

</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2853424"></a><h3>
<a name="g-type-module-use"></a>g_type_module_use ()</h3>
<a class="indexterm" name="id2853437"></a><pre class="programlisting"><a
href="./../glib/glib/glib-Basic-Types.html#gboolean"
>gboolean</a>            g_type_module_use                   (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module);</pre>
<p>
Increases the use count of a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> by one. If the
use count was zero before, the plugin will be loaded.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>
<a
href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"
><code class="literal">FALSE</code></a> if the plugin needed to be loaded and
          loading the plugin failed.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2853521"></a><h3>
<a name="g-type-module-unuse"></a>g_type_module_unuse ()</h3>
<a class="indexterm" name="id2853534"></a><pre class="programlisting">void                g_type_module_unuse                 (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module);</pre>
<p>
Decreases the use count of a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> by one. If the
result is zero, the module will be unloaded. (However, the
<a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> will not be freed, and types associated with the
<a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> are not unregistered. Once a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> is 
initialized, it must exist forever.)
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>


</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2853622"></a><h3>
<a name="g-type-module-set-name"></a>g_type_module_set_name ()</h3>
<a class="indexterm" name="id2853636"></a><pre class="programlisting">void                g_type_module_set_name              (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name);</pre>
<p>
Sets the name for a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a> 
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></p></td>
<td>a human-readable name to use in error messages.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2853720"></a><h3>
<a name="g-type-module-register-type"></a>g_type_module_register_type ()</h3>
<a class="indexterm" name="id2853734"></a><pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType">GType</a>               g_type_module_register_type         (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         <a class="link" href="gobject-Type-Information.html#GType">GType</a> parent_type,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *type_name,
                                                         const <a class="link" href="gobject-Type-Information.html#GTypeInfo">GTypeInfo</a> *type_info,
                                                         <a class="link" href="gobject-Type-Information.html#GTypeFlags">GTypeFlags</a> flags);</pre>
<p>
Looks up or registers a type that is implemented with a particular
type plugin. If a type with name <em class="parameter"><code>type_name</code></em> was previously registered,
the <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> identifier for the type is returned, otherwise the type
is newly registered, and the resulting <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> identifier returned.
</p>
<p>
When reregistering a type (typically because a module is unloaded
then reloaded, and reinitialized), <em class="parameter"><code>module</code></em> and <em class="parameter"><code>parent_type</code></em> must
be the same as they were previously.
</p>
<p>
As long as any instances of the type exist, the type plugin will
not be unloaded.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>parent_type</code></em>&#160;:</span></p></td>
<td>   the type for the parent class
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type_name</code></em>&#160;:</span></p></td>
<td>     name for the type
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type_info</code></em>&#160;:</span></p></td>
<td>     type information structure
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></p></td>
<td>         flags field providing details about the type
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the new or existing type ID


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2853935"></a><h3>
<a name="g-type-module-add-interface"></a>g_type_module_add_interface ()</h3>
<a class="indexterm" name="id2853949"></a><pre class="programlisting">void                g_type_module_add_interface         (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         <a class="link" href="gobject-Type-Information.html#GType">GType</a> instance_type,
                                                         <a class="link" href="gobject-Type-Information.html#GType">GType</a> interface_type,
                                                         const <a class="link" href="gobject-Type-Information.html#GInterfaceInfo">GInterfaceInfo</a> *interface_info);</pre>
<p>
Registers an additional interface for a type, whose interface
lives in the given type plugin. If the interface was already registered
for the type in this plugin, nothing will be done. 
</p>
<p>
As long as any instances of the type exist, the type plugin will
not be unloaded.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td>a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>instance_type</code></em>&#160;:</span></p></td>
<td>type to which to add the interface.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interface_type</code></em>&#160;:</span></p></td>
<td>interface type to add
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interface_info</code></em>&#160;:</span></p></td>
<td>type information structure


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2854078"></a><h3>
<a name="g-type-module-register-enum"></a>g_type_module_register_enum ()</h3>
<a class="indexterm" name="id2854093"></a><pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType">GType</a>               g_type_module_register_enum         (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name,
                                                         const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GEnumValue">GEnumValue</a> *const_static_values);</pre>
<p>
Looks up or registers an enumeration that is implemented with a particular
type plugin. If a type with name <em class="parameter"><code>type_name</code></em> was previously registered,
the <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> identifier for the type is returned, otherwise the type
is newly registered, and the resulting <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> identifier returned.
</p>
<p>
As long as any instances of the type exist, the type plugin will
not be unloaded.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td>             a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></p></td>
<td>               name for the type
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>const_static_values</code></em>&#160;:</span></p></td>
<td>an array of <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GEnumValue"><span class="type">GEnumValue</span></a> structs for the possible
  enumeration values. The array is terminated by a struct with all 
  members being 0.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the new or existing type ID
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.6


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2854250"></a><h3>
<a name="g-type-module-register-flags"></a>g_type_module_register_flags ()</h3>
<a class="indexterm" name="id2854266"></a><pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType">GType</a>               g_type_module_register_flags        (<a class="link" href="GTypeModule.html" title="GTypeModule">GTypeModule</a> *module,
                                                         const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name,
                                                         const <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GFlagsValue">GFlagsValue</a> *const_static_values);</pre>
<p>
Looks up or registers a flags type that is implemented with a particular
type plugin. If a type with name <em class="parameter"><code>type_name</code></em> was previously registered,
the <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> identifier for the type is returned, otherwise the type
is newly registered, and the resulting <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> identifier returned.
</p>
<p>
As long as any instances of the type exist, the type plugin will
not be unloaded.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em>&#160;:</span></p></td>
<td>             a <a class="link" href="GTypeModule.html" title="GTypeModule"><span class="type">GTypeModule</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></p></td>
<td>               name for the type
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>const_static_values</code></em>&#160;:</span></p></td>
<td>an array of <a class="link" href="gobject-Enumeration-and-Flag-Types.html#GFlagsValue"><span class="type">GFlagsValue</span></a> structs for the possible
  flags values. The array is terminated by a struct with all 
  members being 0.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>the new or existing type ID
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.6


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2854422"></a><h3>
<a name="G-DEFINE-DYNAMIC-TYPE:CAPS"></a>G_DEFINE_DYNAMIC_TYPE()</h3>
<a class="indexterm" name="id2854438"></a><pre class="programlisting">#define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P)          G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
</pre>
<p>
A convenience macro for dynamic type implementations, which declares a
class initialization function, an instance initialization function (see 
<a class="link" href="gobject-Type-Information.html#GTypeInfo"><span class="type">GTypeInfo</span></a> for information about these) and a static variable named 
<em class="parameter"><code>t_n</code></em>_parent_class pointing to the parent class. Furthermore, 
it defines a <code class="function">*<code class="function">_get_type()</code></code> and a static 
<code class="function">*<code class="function">_register_type()</code></code> function for use in your
<code class="function"><code class="function">module_init()</code></code>.
See <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS"><code class="function">G_DEFINE_DYNAMIC_TYPE_EXTENDED()</code></a> for an example.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>TN</code></em>&#160;:</span></p></td>
<td>The name of the new type, in Camel case.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>t_n</code></em>&#160;:</span></p></td>
<td>The name of the new type, in lowercase, with words
  separated by '_'.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>T_P</code></em>&#160;:</span></p></td>
<td>The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> of the parent type.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2854593"></a><h3>
<a name="G-DEFINE-DYNAMIC-TYPE-EXTENDED:CAPS"></a>G_DEFINE_DYNAMIC_TYPE_EXTENDED()</h3>
<a class="indexterm" name="id2854609"></a><pre class="programlisting">#define             G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE)</pre>
<p>
A more general version of <a class="link" href="GTypeModule.html#G-DEFINE-DYNAMIC-TYPE:CAPS"><code class="function">G_DEFINE_DYNAMIC_TYPE()</code></a> which
allows to specify <a class="link" href="gobject-Type-Information.html#GTypeFlags"><span class="type">GTypeFlags</span></a> and custom code.
</p>
<div class="informalexample">
<pre class="programlisting">
G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget,
                                gtk_gadget,
                                GTK_TYPE_THING,
                                0,
                                G_IMPLEMENT_INTERFACE (TYPE_GIZMO,
                                                       gtk_gadget_gizmo_init));
</pre>
expands to
<pre class="programlisting">
static void     gtk_gadget_init              (GtkGadget      *self);
static void     gtk_gadget_class_init        (GtkGadgetClass *klass);
static void     gtk_gadget_class_finalize    (GtkGadgetClass *klass);

static gpointer gtk_gadget_parent_class = NULL;
static GType    gtk_gadget_type_id = 0;

static void     gtk_gadget_class_intern_init (gpointer klass)
{
  gtk_gadget_parent_class = g_type_class_peek_parent (klass); 
  gtk_gadget_class_init ((GtkGadgetClass*) klass); 
}

GType
gtk_gadget_get_type (void)
{
  return gtk_gadget_type_id;
}

static void
gtk_gadget_register_type (GTypeModule *type_module)
{
  const GTypeInfo g_define_type_info = {
    sizeof (GtkGadgetClass),
    (GBaseInitFunc) NULL,
    (GBaseFinalizeFunc) NULL,
    (GClassInitFunc) gtk_gadget_class_intern_init,
    (GClassFinalizeFunc) gtk_gadget_class_finalize,
    NULL,   /* class_data */
    sizeof (GtkGadget),
    0,      /* n_preallocs */
    (GInstanceInitFunc) gtk_gadget_init, 
    NULL    /* value_table */
  };
  gtk_gadget_type_id = g_type_module_register_type (type_module,
                                                    GTK_TYPE_THING,
                                                    GtkGadget,
                                                    &amp;g_define_type_info,
                                                    (GTypeFlags) flags);
  {
    const GInterfaceInfo g_implement_interface_info = {
      (GInterfaceInitFunc) gtk_gadget_gizmo_init
    };
    g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &amp;g_implement_interface_info);
  }
}
</pre>
</div>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>TypeName</code></em>&#160;:</span></p></td>
<td>The name of the new type, in Camel case.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type_name</code></em>&#160;:</span></p></td>
<td>The name of the new type, in lowercase, with words
  separated by '_'.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>TYPE_PARENT</code></em>&#160;:</span></p></td>
<td>The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> of the parent type.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></p></td>
<td>
<a class="link" href="gobject-Type-Information.html#GTypeFlags"><span class="type">GTypeFlags</span></a> to pass to <a class="link" href="GTypeModule.html#g-type-module-register-type"><code class="function">g_type_module_register_type()</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>CODE</code></em>&#160;:</span></p></td>
<td>Custom code that gets inserted in the *<code class="function">_get_type()</code> function.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14


</p>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2852684"></a><h2>See Also</h2>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a class="link" href="GTypePlugin.html" title="GTypePlugin"><span class="type">GTypePlugin</span></a></span></p></td>
<td><p>The abstract type loader interface.</p></td>
</tr>
<tr>
<td><p><span class="term"><a
href="./../glib/glib/glib-Dynamic-Loading-of-Modules.html#GModule"
><span class="type">GModule</span></a></span></p></td>
<td><p>Portable mechanism for dynamically loaded modules.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2855012"></a><div class="refsect2" lang="en"><a name="id2855013"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id2855014"></a></div>
</div>
</div>
</body>
</html>
